package com.zy.teacherSide.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zy.teacherSide.entity.Course;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 29787
 */
@Mapper
@Component
public interface CourseDao extends BaseMapper<Course> {

    /**
     * 根据课程名，教师id，班级id查询当前课程是否已经创建
     * @param courseName
     * @param teacherId
     * @param classroomId
     * @return Course
     */
    @Select("select * from hms_course where course_name=#{courseName} and teacher_id=#{teacherId} and classroom_id=#{classroomId}")
    Course getCourse(String courseName,Integer teacherId,Integer classroomId);

    /**
     * 根据教师id，班级id查询课程
     * @param teacherId
     * @param classroomId
     * @return List<Course>
     */
    @Select("select * from hms_course where teacher_id=#{teacherId} and classroom_id=#{classroomId}")
    List<Course> getCourseByClassroomIdAndTeacherId(Integer teacherId,Integer classroomId);


    /**
     * 根据课程名，教师id查询当前课程
     * @param courseName
     * @param teacherId
     * @return Course
     */
    @Select("select * from hms_course where course_name=#{courseName} and teacher_id=#{teacherId}")
    Course getCourseByCourseNameAndTeacherId(String courseName,Integer teacherId);

    /**
     * 根据教师id查询课程信息
     * @param teacherId
     * @return List<Course>
     */
    @Select("select * from hms_course where teacher_id=#{teacherId}")
    List<Course> getAllCourse(Integer teacherId);

    /**
     * 根据课程id和教师id查询课程信息
     * @param teacherId
     * @param courseId
     * @return Course
     */
    @Select("select * from hms_course where teacher_id=#{teacherId} and course_id=#{courseId}")
    Course getAllCourseByCourseId(Integer teacherId,Integer courseId);

    /**
     * 根据课程id和教师id查询课程信息
     * @param teacherId
     * @return List<Course>
     */
    @Select("select * from hms_course where teacher_id=#{teacherId} and classroom_id=#{classroomId}")
    List<Course> getAllCourseByTeacherIdAndClassroomId(Integer teacherId,Integer classroomId);

}
